<?php
require "../common/user_online.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>EbookAZ</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<?php require "../components/head.php" ?>
</head>
<body onload="MakeCurrentPage(1)">
<div id="container">
	<?php require "../components/admin_menu.php" ?>
	<?php require "../components/admin_header.php" ?>
	<div id="content">
		<?php require "../components/content_left.php"?>
		<div id="content_right">
        <?php
 
		include "../common/db.inc";
		$mysqli = new mysqli($host, $username, $password,$dbname);
		$mysqli->set_charset('utf8');	

		/* check connection */
		if (mysqli_connect_errno()) {
		    printf("Connect failed: %s\n", mysqli_connect_error());
		    exit();
		}

		$id = $_REQUEST["id"];	
		$query = ("call sp_GetUncheckedEbookDetail('$id')");

		if ($result = $mysqli->query($query)) 
		{		
			//lay thong tin ebook
			$row = mysqli_fetch_row($result);
			$ebookId = $row[0];
			$title = $row[1];
			$file_up = $row[2];				
			$type = $row[3];		
			$description = $row[4];
			$author = $row[5];
			$publisher = $row[6];	
			$pagenum = $row[7];				
			$coverimg = "$image$row[8]";
			$size = $row[9];	
			$category = $row[10];			
			$updatedate = $row[11];
			$userid = $row[12];
			$field = $row[13];
			
			if($pagenum == 0)
				$pagenum = "<i>Đang cập nhật<i>";
	
			$arr = date_parse($updatedate);
			$ngay = $arr['day'];
			$thang = $arr['month'];
			$nam = $arr['year'];
			if ($ngay < 10)
				$ngay = "0" . $ngay;
			if ($thang < 10)
				$thang = "0" . $thang;
			$updatedate = $ngay . "/" . $thang . "/" . $nam;

		
			echo "<h1 align='center' width='300px'> Chi tiết sách</h1>";
			echo "<form action='checkbook.php' method='post'>";
			echo "<table>";
			echo "<tr>";
			echo "<td valign='top' align='center' width='250px'><img width='200' height='300' src='$coverimg' alt='book image' /></td>";
			echo "<td valign='top'>";
			echo "<input name='id' type='hidden' value='$ebookId' size='5px'/>";
			echo "<label style='color: blue; font-size:13px;'><b>$title</b></label><br>";
			echo "<b>Tác giả: </b>$author<br/>";
			echo "<b>NXB: </b>$publisher<br/>";
			echo "<b>Loại: </b>$type<br/>";
			echo "<b>File tải lên: </b>$file_up<br/>";
			echo "<b>Danh mục: </b>$field >> $category<br/>";
			echo "<b>Số trang: </b>$pagenum<br/>";
			echo "<b>Kích thước: </b>$size<label> Kb</label><br/>";
			echo "<b>Ngày cập nhật: </b>$updatedate<br/><br>";			
			echo "<b>Mô tả: </b><br><div>$description</div><br/><br/>";
			echo "<b>Mana:</b><input name='txtMana' type='text' value=100 size='5px' onblur='checkMana()'/><b id='bMana'></b><br/>";	
			echo "</td>";			
			echo "</tr >";			
			echo "</table><br><br/>";			
			
			echo "<hr width='600px' />";
			echo "<div align='center'>";
			echo "<input type='button' name='btnEdit' value='Sửa' onClick='edit($id)'/>&nbsp;&nbsp;&nbsp;";
			echo "<input type='button' name='btnCheck' value='Duyệt' onclick='CheckBook({$ebookId})'/>";
			echo "</div>";
			echo "</form>";
			echo "<br><br><br>";
			$result->close();
		}
		
		$mysqli->close();		

		?>
		</div>
	</div>
	<?php require "../components/footer.php" ?>
</div>
</body>
</html>
